/*
 * ForwardIndexGen.h
 *
 *  Created on: Sep 24, 2011
 *      Author: srihari
 */

#ifndef FORWARDINDEXGEN_H_
#define FORWARDINDEXGEN_H_

#include "../DocumentRepresentation/CDocument.h"
#include "../include/includes.h"
#include "../include/CUtilities.h"
using namespace std;

struct fwdPosting {
	size_t termId;
	int offset;
	int semWikiPart;
	// int termFreq;
};

typedef map<size_t, vector<fwdPosting*> > FWDINDEXMAPTYPE;

class ForwardIndexGen {
	static ForwardIndexGen* instance;
	map<string, termData> tokenTermMap;
	map<int, string> semWikiData;

	map<size_t, vector<fwdPosting*> > fwdIndex;
	typedef pair<size_t, vector<fwdPosting*> > fwdIndexValue;
	map<int, vector<size_t> > semWikiTerms;

	size_t noOfFilesProc;
	int curBarrel;
	int barrelSize;
public:
	ForwardIndexGen();
	virtual ~ForwardIndexGen();
	static ForwardIndexGen* getInstance();

	void generateFwdIndex(CDocument& doc, int docType);
	vector<fwdPosting*> createPostingsForPart(string& data, int semWikiPart);

	map<string, termData> getTokenTermMap() const {
		return tokenTermMap;
	}

	void setTokenTermMap(map<string, termData> tokenTermMap) {
		this->tokenTermMap = tokenTermMap;
	}

	void writeToDisk();

};

#endif /* FORWARDINDEXGEN_H_ */
